import { login } from '@/api/user'
import { setToken, getToken } from '@/utils/storage'
export default {
  // 开启命名空间
  namespaced: true,
  state: {
    token: getToken() || ''
  },
  mutations: {
    updateToken (state, token) {
      state.token = token
      setToken(token)
    }
  },
  actions: {
    // 登录
    async loginAction (context, obj) {
    //   console.log('发请求', obj)
      const res = await login(obj)
      console.log(res)
      context.commit('updateToken', res.data.token)
    }
  },
  getters: {}
}
